<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page import="com.bean.LoginBean"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'userinfo.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
 
  <body>
<%Class.forName("com.mysql.jdbc.Driver").newInstance(); 
String url="jdbc:mysql://localhost:3306/graduatedesign";  
String user="root";  
String password="root";
LoginBean LoginBean= (LoginBean)session.getAttribute("Loginbean");
Connection conn = DriverManager.getConnection(url, user, password); 
Connection conn3 = DriverManager.getConnection(url, user, password); 
Statement sm=conn.createStatement();
String id=request.getParameter("id");
Statement sm3=conn3.createStatement();
ResultSet rs3=sm3.executeQuery("select distinct dept from dept");
Connection conn2 = DriverManager.getConnection(url, user, password); 
Statement sm2=conn2.createStatement();
ResultSet rs2=sm2.executeQuery("select distinct role from role");
ResultSet rs=sm.executeQuery("select a.username,a.password,a.utype,b.name,sex,age,tel,email,dept,status from user as a inner join userinfo as b on a.username=b.username where a.id="+id); 
if(rs.next())
{%>
    <form name="f1" method="post"
		action="useredit?id=<%=id %>" onsubmit="return ck()">
		<table width="100%" border="0" cellpadding="0" cellspacing="1"
			bgcolor="#BBD3EB">
			
			<tr>
            <td height="27" align="center" background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">用户名</td>
            <td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input style="border:1px;border-bottom-style:none;border-top-style:none;border-left-style:none;border-right-style:none;" type="text" id="username" name="username" size="50" value="<%=rs.getString(1)%>" readonly="readonly"/></td>
    						</tr>
			<tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">密码</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="password"
					id="password" name="password" value="<%=rs.getString(2)%>" /></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">角色权限</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;
                            	<select name=role id=role>
                              <% 
                               while(rs2.next()){%>
                                <option value='<%=rs2.getString(1)%>'<%if(rs2.getString(1).equals(rs.getString(3))){out.print(" selected=\"true\"");}%>><%=rs2.getString(1)%></option>
                               <% } %>
                                  </select></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">姓名</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="text"
					id="name" name="name" value="<%=rs.getString(4)%>" /></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">年龄</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="text"
					id="age" name="age" value="<%=rs.getString(6)%>" /></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">性别</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<select id="sex"
					name="sex">
						<option value="男"<%if(rs.getString(5).equals("男")){out.print(" selected=\"true\"");}%>>男</option>
						<option value="女"<%if(rs.getString(5).equals("女")){out.print(" selected=\"true\"");}%>>女</option>
				</select></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">电话</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="text"
					id="tel" name="tel" value="<%=rs.getString(7)%>" /></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">EMAIL</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="text"
					id="email" name="email" value="<%=rs.getString(8)%>" /></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">部门</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<select name=dept id=dept>
                               <% 
                               while(rs3.next()){%>
                                <option value='<%=rs3.getString(1)%>'<%if(rs3.getString(1).equals(rs.getString(9))){out.print(" selected=\"true\"");}%>><%=rs3.getString(1)%></option>
                               <% } %> 
                                  </select></td>
			</tr>
			<tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">状态</td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<select id="status"
					name="status">
						<option value="在职"<%if(rs.getString(10).equals("在职")){out.print(" selected=\"true\"");}%>>在职</option>
						<option value="离职"<%if(rs.getString(10).equals("离职")){out.print(" selected=\"true\"");}%>>离职</option>
						<option value="实习"<%if(rs.getString(10).equals("实习")){out.print(" selected=\"true\"");}%>>实习</option>
				</select></td>
			</tr>
				<td height="27" align="center"
					background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF"></td>
				<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;<input type="submit"
					value="提交" /></td>
			</tr>
		<script language="javascript">
                              function ck(){
                            	if(f1.title.value==""){
                            		alert("角色名不能为空");
                            		return false;
                            	}
                            	alert("操作成功");
                            }
                            </script>
		</table>
	</form>
	  <%} %>
  </body>
</html>
